package com.lsa.letcode.the139.wordBreak;

import static org.junit.Assert.*;

import java.util.Arrays;
import java.util.HashSet;

import org.junit.Test;

import com.lsa.letcode.common.LetCodeTestBase;

public class WordBreakTest extends LetCodeTestBase {
	@Test
	public void test() throws Exception {
		Solution s = new Solution();
		assertTrue(s.wordBreak("codeleetcode", new HashSet<>(Arrays.asList("leet","code"))));
		assertTrue(s.wordBreak("leetcode", new HashSet<>(Arrays.asList("leet","code"))));
		assertTrue(s.wordBreak("codeleetcode", new HashSet<>(Arrays.asList("leet","code", "eleetco"))));
		assertTrue(s.wordBreak("leet     code", new HashSet<>(Arrays.asList("leet","code"))));
		assertFalse(s.wordBreak("leetcode", new HashSet<>(Arrays.asList("leet","cod"))));
		
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < 1000; i++) {
			if (i % 2 == 0){
				sb.append("leet");
			}
			else {
				sb.append("code");
			}
		}
		assertTrue(s.wordBreak(sb.toString(), new HashSet<>(Arrays.asList("leet","code"))));
		assertFalse(s.wordBreak(sb.toString()+"gandalf", new HashSet<>(Arrays.asList("leet","code"))));
	}
}
